package flc.ast.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.databinding.ActivityDareBinding;
import stark.common.basic.event.EventStatProxy;

public class DareActivity extends BaseAc<ActivityDareBinding> {

    private List<String> listDare = new ArrayList<>();
    private int tmpPos = 0;

    @Override
    protected int onCreate() {
        return R.layout.activity_dare;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);

        mDataBinding.ivDareBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.ivDareNext.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.ivDareNext://下一题
                if (tmpPos == listDare.size() - 1) {
                    ToastUtils.showShort(getString(R.string.is_last_question));
                    return;
                }
                tmpPos++;
                setContent();
                break;
        }
    }

    @Override
    protected void initData() {
        listDare = Arrays.asList(getResources().getStringArray(R.array.dare_questions));
        Collections.shuffle(listDare);
        setContent();
    }

    private void setContent() {
        mDataBinding.tvDareContent.setText(listDare.get(tmpPos));
    }

}